package com.runen.wnhz.runen.ui.adapter.puadapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.util.Log;
import android.view.ViewGroup;

import com.runen.wnhz.runen.data.entity.AllDataEntity;
import com.runen.wnhz.runen.data.entity.BaseEntity;
import com.runen.wnhz.runen.data.entity.FragmentInfo;
import com.runen.wnhz.runen.data.entity.ShopInfo;
import com.runen.wnhz.runen.data.entity.ShopTypeEntity;
import com.runen.wnhz.runen.ui.fragment.publicm.AllFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018-04-23.
 * <p>
 * 数据服务的viewpagerAdapter
 */

public class ViewPagerAdapter extends FragmentPagerAdapter {

    private List<FragmentInfo> mDatas = new ArrayList<>();
    private List<ShopTypeEntity> mlist;
    private String currentShopTypeId;
    private List<Fragment> fragments;

    /**
     * 第一个参数：fragment 适配器
     * 第二个参数：服务器请求回来的title  根据这个title 进行增加对于的recyclerview
     */
    public ViewPagerAdapter(FragmentManager fm, List<ShopTypeEntity> title, List<Fragment> fragments) {
        super(fm);
        this.mlist = title;
        this.fragments = fragments;
        this.currentShopTypeId = currentShopTypeId;
    }

    public void update(int poi, List<ShopInfo> shopInfoList,String currentShopTypeId,String sDate,String eDate,String pageNum) {
        AllFragment fragment = (AllFragment) fragments.get(poi);
        Log.d("currentShopTypeId",currentShopTypeId);
        fragment.update(shopInfoList,currentShopTypeId,sDate,eDate,pageNum);
    }


    @Override
    public Fragment getItem(int position) {

        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return (CharSequence) fragments.get(position).getArguments().get("title");
    }


}
